package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
/**
 *用户持久层接口
 * @author msi
 * @date 2022/5/17
 * @version 1.0
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {
    /**
     * 根据电话查找
     * @param phone 电话号码
     * @return 用户对象
     */
    @Select("select id, username, password, phone, status from reggie.user where phone=#{phone}")
    User selectByPhone(String phone);

    /**
     * 添加用户
     * @param user 用户对象
     */
    @Insert("insert into reggie.user (id, username, password, phone, status) value" +
            "(#{id},#{username},#{password},#{phone},#{status})")
    void addUser(User user);
}
